package com.datangnet.parking.basecommon.exception;

import org.apache.commons.lang3.StringUtils;


public class SysException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	
	/**  错误编号  */
	private String errorCode = ExceptionCode.code_failed;
	/**  错误描述  */
	private String errorDesc = ExceptionCode.desc_failed;

	public SysException() {
		super();
	}
	
	public SysException(String desc) {
		this(null, desc);
	}
	
	public SysException(String errorCode, String desc) {
		super();
		
		if (StringUtils.isNotBlank(errorCode)) {
			this.errorCode = errorCode;
		}
		
		if (desc!=null) { // 仅仅判断是否为null. 这就意味着允许用空串.
			this.errorDesc = desc;
		}
	}
	
	public SysException(Throwable cause) {
		super(cause);
	}

	public SysException(String desc, Throwable cause) {
		super(desc, cause);
		this.errorDesc = desc;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorDesc() {
		return errorDesc;
	}

	public void setErrorDesc(String errorDesc) {
		this.errorDesc = errorDesc;
	}
	
	public String print() {
		return errorDesc+"("+this.errorCode+")";
	}
}
